package com.lxw.oa.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/**
 * Created by Administrator on 2019/4/15.
 */
public class Test {

    public  static  void main(String [] args){
        String cookieId[]={"0","1","2","3","4","5","6","7","8","9","Z","Y","X","W","V","U","T","S","R",
                "Q","P","O","N","M","L","K","J","I","H","G","F","E","D","C","B","A"};
        String regionId[]={"G01","G05","G04","G03","G02"};
        String osId[]={"Android 5.0","Mac OS","Window 7"};
        String tempDate=null;
        String cookieIdTemp="";
        String regionTemp=null;
        String cityTemp =null;
        String sidTemp=null;
        String osTemp=null;
        String pvTemp=null;

        try{
            for(int i=0;i<100;i++){
                int x=(int)(Math.random()*31);
                if(x==0){
                    tempDate="2016-07-01";
                }else if(x<10) {
                    tempDate = "2016-07-0" + x;
                }else {
                    tempDate="2016-07-"+x;
                }


            for(int i1=0;i1<18;i1++){
                int j=(int)(Math.random()*35);
                cookieIdTemp+=cookieId[j];
            }

            int k=(int)(Math.random()*4);
            regionTemp=regionId[k];

            int l=(int)(Math.random()*2)+1;
            cityTemp=regionTemp+"0"+1;

            Random random=new Random();
            int m=(int) Math.floor((random.nextDouble()*10000.0));
            sidTemp=""+m;

            int n=(int)(Math.random()*2);
            osTemp=osId[n];

            int h=(int)(Math.random()*9)+1;
            pvTemp=""+h;
            String data=tempDate+"|"+cookieIdTemp+"|"+regionTemp+"|"+cityTemp+"|"+sidTemp+"|"+
                    osTemp+"|"+pvTemp+"\n";
            cookieIdTemp="";

            File file=new File("fact_data.txt");
            if(!file.exists()){
                file.createNewFile();
            }

            FileWriter fileWriter=new FileWriter(file.getName(),true);
            BufferedWriter bufferedWriter=new BufferedWriter(fileWriter);
            bufferedWriter.write(data);
            bufferedWriter.close();

            }

        }catch (IOException e){
            e.printStackTrace();;
        }

    }

}
